package msh.bean;

import java.io.Serializable;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import mysweethome.entities.Customer;
import mysweethome.sessionbean.CustomerBizLocal;

@ManagedBean
@SessionScoped
public class CustomerBean implements Serializable {
    private String username;
    private String password;
    private boolean login;
    private Customer customer;
    private boolean rememberMe;
    @EJB
    private CustomerBizLocal cusBiz;
   
    
    
    public String loginAction(){
      // FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Correct", "Correct");
      // FacesContext.getCurrentInstance().addMessage(null, msg);
        try {                   
            login = cusBiz.checkLogin(username, password);
            if(login){
                return "loginSuccess";
            }
            else{
                return "loginFail";
            }
        } catch (Exception ex) {
            return "error";
        }
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public boolean isLogin() {
        return login;
    }

    public void setLogin(boolean login) {
        this.login = login;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }


}
